package com.tjbklx1.zk.testzkclient;

import java.util.List;

import org.I0Itec.zkclient.IZkChildListener;
import org.I0Itec.zkclient.ZkClient;
import org.I0Itec.zkclient.serialize.SerializableSerializer;

public class SubscribeChildChanges {

	private static class ZkChildListener implements IZkChildListener {

		public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception {
			System.out.println(parentPath);
			System.out.println(currentChilds.toString());
		}

	}

	public static void main(String[] args) throws InterruptedException {
		ZkClient zc = new ZkClient("127.0.0.1:2181", 10000, 10000, new SerializableSerializer());
		System.out.println("conneted ok!");

		zc.subscribeChildChanges("/cli", new ZkChildListener());
		Thread.sleep(Integer.MAX_VALUE);

	}

}